# 标准模块Pickle支持持久化对象到文件

import pickle

shoplistfile = "shoplist.data"

shoplist = ['carrot', 'apple', 'mango']

f = open(shoplistfile, 'wb')
# 持久化
pickle.dump(shoplist, f)
f.close()

del shoplist

f = open(shoplistfile, 'rb')
# 读取
storedlist = pickle.load(f)
print(storedlist)
